package com.zxkj.commonpatrol.adapt;

import android.content.res.ColorStateList;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.czy.basecommon.utils.base.BaseRepository;
import com.google.android.material.button.MaterialButton;
import com.xuexiang.xui.widget.progress.materialprogressbar.MaterialProgressBar;
import com.zxkj.commonpatrol.R;
import com.zxkj.commonpatrol.model.response.DevEvtQuestPatrolHistoryResponse;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;


public class QuestButtonAdapt extends BaseQuickAdapter<DevEvtQuestPatrolHistoryResponse.QItemAction, BaseViewHolder> {

    public void setmDataCallBack(MyItemDataCallBack mDataCallBack) {
        this.mDataCallBack = mDataCallBack;
    }

    public MyItemDataCallBack mDataCallBack;

    //数据回调接口
    public interface MyItemDataCallBack<T> {
        void onDataSuccessCallBack( T t);
        void onDataFailCallBack(T t,T t1);
    }


    public QuestButtonAdapt(int layoutResId, @Nullable List<DevEvtQuestPatrolHistoryResponse.QItemAction> data) {
        super(layoutResId, data);
    }




    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, @Nullable DevEvtQuestPatrolHistoryResponse.QItemAction qItemAction) {
         MaterialButton button=baseViewHolder.itemView.findViewById(R.id.btn);
         button.setText(qItemAction.ActName);
         if (qItemAction.Irregular==0){
               //yes

             button.setBackgroundColor(getContext().getColor(R.color.green));
             button.setIcon(getContext().getDrawable(R.drawable.btn_yes));
         }else{
             button.setBackgroundColor(getContext().getColor(R.color.red));
               //no

             button.setIcon(getContext().getDrawable(R.drawable.btn_no));
         }
         button.setOnClickListener(v->{
             mDataCallBack.onDataSuccessCallBack(baseViewHolder.getLayoutPosition());
         });


    }
}
